package Demo4;

import org.w3c.dom.ls.LSOutput;

public class Computer {
    public void poweron(){
        System.out.println("电脑开机");
    }

//    public void poweron(){
//        System.out.println("电脑开机");
//    }

    public void useService(IUsb usb){
        usb.openDevice();
        if(usb instanceof Mouse){
            Mouse mouse=(Mouse) usb;
            mouse.click();
        }
        else if(usb instanceof KeyBoard){
            KeyBoard computer=(KeyBoard) usb;
            computer.input();
        }
        usb.closeDevice();
    }

    public void poweroff(){
        System.out.println("电脑关机");
    }
}
